// import { Process, Exception, time } from "./__types/yao";

function beforeSave(payload) {
  var id = Process("session.Get", "user_id");
  payload["oper_id"] = id;
  // console.log("beforeSave-payload-->", payload);
  return [payload];
}

function save(payload) {
  console.log("save-payload-->", payload);
  var task_confs = Process("models.task_conf.Get", { wheres: [{ "column": "sku", "op": "=", "value": payload.sku }] });
  if (task_confs.length > 0 && !payload.id) {
    throw new Exception("SKU已存在");
  }
  let id = Process("models.task_conf.Save", payload);
  return { "id": id };
}

function GetSKU(param) {
  console.log("param--->", param)
  var query = new Query();

  var res = query.Get({
    select: ["sku as value", ":concat(name,'(',sku,')') as label"],
    from: "product",
    wheres: [{ "field": "deleted_at", "op": "null" }]
    // wheres: [{ ":deleted_at": "删除时间", is: "null" }]
  });

  return res;
}